<%--
  Created by IntelliJ IDEA.
  User: zhongge
  Date: 2025/8/16
  Time: 1:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>学生信息详情</title>
    <style>
        .container { width: 60%; margin: 30px auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; }
        h1 { color: #333; text-align: center; }
        .info-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
        .info-table th, .info-table td { border: 1px solid #eee; padding: 12px; text-align: left; }
        .info-table th { width: 30%; background-color: #f5f5f5; }
        .btn { display: inline-block; padding: 8px 15px; text-decoration: none; color: #fff; border-radius: 3px; margin-right: 10px; }
        .back-btn { background-color: #6c757d; }
        .edit-btn { background-color: #2196F3; }
        .delete-btn { background-color: #f44336; }
        .no-data { text-align: center; padding: 50px; color: #666; font-size: 18px; }
        .action-buttons { margin-top: 20px; text-align: center; }
    </style>
</head>
<body>
<div class="container">
    <h1>学生信息详情</h1>

    <!-- 当查询到学生信息时显示 -->
    <c:if test="${not empty student}">
        <table class="info-table">
            <tr>
                <th>ID</th>
                <td>${student.id}</td>
            </tr>
            <tr>
                <th>姓名</th>
                <td>${student.name}</td>
            </tr>
            <tr>
                <th>年龄</th>
                <td>${student.age}</td>
            </tr>
            <tr>
                <th>性别</th>
                <td>${student.sex == 1 ? '男' : '女'}</td>
            </tr>
            <tr>
                <th>生日</th>
                <td>${student.birthday}</td>
            </tr>
            <tr>
                <th>地址</th>
                <td>${student.address}</td>
            </tr>
            <tr>
                <th>备注</th>
                <td>${student.remark}</td>
            </tr>
        </table>

        <div class="action-buttons">
            <a href="${pageContext.request.contextPath}/list" class="btn back-btn">返回列表</a>
            <a href="${pageContext.request.contextPath}/update?id=${student.id}" class="btn edit-btn">编辑</a>
            <a href="student/deleteServlet?id=${student.id}" class="btn delete-btn"
               onclick="return confirm('确定要删除该学生信息吗？')">删除</a>
        </div>
    </c:if>

    <!-- 当未查询到学生信息时显示 -->
    <c:if test="${empty student}">
        <div class="no-data">
            <p>没有找到ID为 ${param.searchId} 的学生信息</p>
            <a href="${pageContext.request.contextPath}/list" class="btn back-btn">返回学生列表</a>
        </div>
    </c:if>
</div>
</body>
</html>

